package com.chenjun.common.util;
/*package com.candowin.common.util;

import org.apache.log4j.Logger;

import com.candowin.common.util.ConfigUtil;
import com.gexin.rp.sdk.base.IPushResult;
import com.gexin.rp.sdk.base.impl.SingleMessage;
import com.gexin.rp.sdk.base.impl.Target;
import com.gexin.rp.sdk.base.payload.APNPayload;
import com.gexin.rp.sdk.exceptions.RequestException;
import com.gexin.rp.sdk.http.IGtPush;
import com.gexin.rp.sdk.template.APNTemplate;
import com.gexin.rp.sdk.template.TransmissionTemplate;


*//** 
 * @Title: AppPushUtils 
 * @Description: 
 * @date 2016年8月23日 下午3:49:26 
 * @version V1.0   
 *//*
public class AppPushUtils {
	private static final Logger logger = Logger.getLogger(AppPushUtils.class);	
	static String appId = ConfigUtil.getValue(null,"ios.appid");
    static String appKey = ConfigUtil.getValue(null,"ios.appkey");
    static String masterSecret = ConfigUtil.getValue(null,"ios.master");
    static String url =ConfigUtil.getValue(null,"ios.host");
    
    public static void apnpush(String msg,String code,String devicetoken) throws Exception {
   	 IGtPush push = new IGtPush(url, appKey, masterSecret);  
        APNTemplate t = new APNTemplate();
        APNPayload apnpayload = new APNPayload();
        apnpayload.setSound("");
        apnpayload.setContentAvailable(1);
        //apn高级推送
        APNPayload.DictionaryAlertMsg alertMsg = new APNPayload.DictionaryAlertMsg();
        ////通知文本消息标题 
        alertMsg.setTitle("");
        //通知文本消息字符串
        alertMsg.setBody(msg);
        //对于标题指定执行按钮所使用的Localizable.strings,仅支持IOS8.2以上版本
        alertMsg.setTitleLocKey("");
        //指定执行按钮所使用的Localiz able.strings
        alertMsg.setActionLocKey("");
        apnpayload.setAlertMsg(alertMsg);
        apnpayload.addCustomMsg("candowin_code", code);

        t.setAPNInfo(apnpayload);
        SingleMessage sm = new SingleMessage();
        sm.setData(t);
        try {
       	 IPushResult ret0 = push.pushAPNMessageToSingle(appId, devicetoken, sm);
       	 if(ret0!=null){
       		 logger.error("个推发送返回"+ret0.getResponse().toString()+"code==="+code);
       	 } 
		} catch (Exception e) {
			//错误日志
		}
   }
   
   
   public static void apnpushAnd(String code,String cid) {
       // https连接
       IGtPush push = new IGtPush(appKey, masterSecret, true);
       // 此处true为https域名，false为http，默认为false。Java语言推荐使用此方式
       // IGtPush push = new IGtPush(host, appkey, master);
       // host为域名，根据域名区分是http协议/https协议
       TransmissionTemplate template = transmissionTemplateDemo(code);
       SingleMessage message = new SingleMessage();
       message.setOffline(true);
       // 离线有效时间，单位为毫秒，可选
       message.setOfflineExpireTime(24 * 3600 * 1000);
       message.setData(template);
       message.setPushNetWorkType(0); // 可选，判断是否客户端是否wifi环境下推送，1为在WIFI环境下，0为不限制网络环境。
       Target target = new Target();
       target.setAppId(appId);
       target.setClientId(cid);
       // 用户别名推送，cid和用户别名只能2者选其一
       // String alias = "个";
       // target.setAlias(alias);
       IPushResult ret = null;
       try {
           ret = push.pushMessageToSingle(message, target);
       } catch (RequestException e) {
           e.printStackTrace();
           ret = push.pushMessageToSingle(message, target, e.getRequestId());
       }
       if (ret != null) {
       	logger.error("个推发送返回"+ret.getResponse().toString()+"code==="+code);
           System.out.println(ret.getResponse().toString());
       } else {
           System.out.println("服务器响应异常");
       }
   }
   
   
   public static TransmissionTemplate transmissionTemplateDemo(String code){
   	TransmissionTemplate template =new TransmissionTemplate();
   	template.setTransmissionType(2);
	    template.setAppId(appId);
	    template.setAppkey(appKey);
	    template.setTransmissionContent(code);
	    iOS 推送需要对该字段进行设置具体参数详见iOS模板说明(PYTHON)
	    return template;
   }
   
    
    public static void appPush(String code,String msg,String uuid,String sourceType) throws Exception{
    	if(sourceType.indexOf("ios")>0){
    		apnpush(msg,code,uuid);
    	}else{
    		apnpushAnd(code,uuid);
    	}
    }
    public static void main(String[] args) {
		try {
			AppPushUtils.apnpush("123123123", "123123123", "FF8DF954-6BED-4AA1-90A3-179A0943C268");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
*/